/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	ComponentPhysics.h
*
*	Description -	Actor component for integrating physics behavior or simply for collision.
*
*	Comments	-	Currently only performs as a rigidbody
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	08/19/2013	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_COMPONENT_PHYSICS_H_
#define _PSX_COMPONENT_PHYSICS_H_

#include "PulseSTD.h"
#include "IComponent.h"

namespace Pulse
{
	PSX_EnumBegin( EColliderType )
		NONE,
		BOX,
		SPHERE,
		//CAPSULE,
		//CYLINDER,
		//CONE,

	PSX_EnumEnd()

	class ComponentPhysics : public IComponent
	{
	public:

		ComponentPhysics( Actor *pOwner );

		virtual ~ComponentPhysics( void );

		virtual EErrorCode::Type Initialize( XMLElementPtr pElem );

		virtual const EComponent::Type GetType( void ) const { return EComponent::PHYSICS; }

		static const EComponent::Type GetType_Static( void ) { return EComponent::PHYSICS; }

		virtual const CHAR * GetName( void ) const { return PSX_String("Physics"); }

		virtual void Update( FLOAT dt );

	public:

		struct ICollider { virtual ~ICollider( void ) { } }; // Pimpl
		struct InternalData; // Pimpl

		const EColliderType::Type GetColliderType( void ) const { return m_colliderType; }

	private:

		// Utilities
		void PSX_NO_DIRECT_CALL OnRemoveCollider( void );

		void Cleanup( void );

	private:

		friend IPhysicsSystem;
		friend BulletPhysics;

		// NOTE: Called by the Physics system
		void PSX_NO_DIRECT_CALL OnManifold( CollisionData pCollisionData );

	private:

		EColliderType::Type m_colliderType;
		ICollider *m_pCollider;
		InternalData *m_pInternalData;

	};
}

#endif /* _PSX_COMPONENT_PHYSICS_H_ */